<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QXmlSimpleReader Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlSimpleReader Class Reference<br /><sup><sup>[<a href="qtxml.html">QtXml</a> module]</sup></sup></h1><p>The QXmlSimpleReader class provides an implementation of a
simple XML parser. <a href="#details">More...</a></p>

<p>Inherits <a href="qxmlreader.html">QXmlReader</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlsimplereader.html#QXmlSimpleReader">__init__</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlContentHandler <b><a href="qxmlsimplereader.html#contentHandler">contentHandler</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlDeclHandler <b><a href="qxmlsimplereader.html#declHandler">declHandler</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlDTDHandler <b><a href="qxmlsimplereader.html#DTDHandler">DTDHandler</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlEntityResolver <b><a href="qxmlsimplereader.html#entityResolver">entityResolver</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlErrorHandler <b><a href="qxmlsimplereader.html#errorHandler">errorHandler</a></b> (<i>self</i>)</li><li><div class="fn" />(bool, bool&#160;<i>ok</i>) <b><a href="qxmlsimplereader.html#feature">feature</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" />bool <b><a href="qxmlsimplereader.html#hasFeature">hasFeature</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" />bool <b><a href="qxmlsimplereader.html#hasProperty">hasProperty</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" />QXmlLexicalHandler <b><a href="qxmlsimplereader.html#lexicalHandler">lexicalHandler</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qxmlsimplereader.html#parse">parse</a></b> (<i>self</i>, QXmlInputSource&#160;<i>input</i>)</li><li><div class="fn" />bool <b><a href="qxmlsimplereader.html#parse-2">parse</a></b> (<i>self</i>, QXmlInputSource&#160;<i>input</i>, bool&#160;<i>incremental</i>)</li><li><div class="fn" />bool <b><a href="qxmlsimplereader.html#parseContinue">parseContinue</a></b> (<i>self</i>)</li><li><div class="fn" />(sip.voidptr, bool&#160;<i>ok</i>) <b><a href="qxmlsimplereader.html#property">property</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setContentHandler">setContentHandler</a></b> (<i>self</i>, QXmlContentHandler&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setDeclHandler">setDeclHandler</a></b> (<i>self</i>, QXmlDeclHandler&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setDTDHandler">setDTDHandler</a></b> (<i>self</i>, QXmlDTDHandler&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setEntityResolver">setEntityResolver</a></b> (<i>self</i>, QXmlEntityResolver&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setErrorHandler">setErrorHandler</a></b> (<i>self</i>, QXmlErrorHandler&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setFeature">setFeature</a></b> (<i>self</i>, QString&#160;<i>name</i>, bool&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setLexicalHandler">setLexicalHandler</a></b> (<i>self</i>, QXmlLexicalHandler&#160;<i>handler</i>)</li><li><div class="fn" /><b><a href="qxmlsimplereader.html#setProperty">setProperty</a></b> (<i>self</i>, QString&#160;<i>name</i>, sip.voidptr&#160;<i>value</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlSimpleReader class provides an implementation of a
simple XML parser.</p>
<p>This XML reader is suitable for a wide range of applications. It
is able to parse well-formed XML and can report the namespaces of
elements to a content handler; however, it does not parse any
external entities. For historical reasons, Attribute Value
Normalization and End-of-Line Handling as described in the XML 1.0
specification is not performed.</p>
<p>The easiest pattern of use for this class is to create a reader
instance, define an input source, specify the handlers to be used
by the reader, and parse the data.</p>
<p>For example, we could use a <a href="qfile.html">QFile</a> to
supply the input. Here, we create a reader, and define an input
source to be used by the reader:</p>
<pre class="cpp">
     <span class="type">QXmlSimpleReader</span> xmlReader;
     <span class="type"><a href="qxmlinputsource.html">QXmlInputSource</a></span> <span class="operator">*</span>source <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qxmlinputsource.html">QXmlInputSource</a></span>(file);
</pre>
<p>A handler lets us perform actions when the reader encounters
certain types of content, or if errors in the input are found. The
reader must be told which handler to use for each type of event.
For many common applications, we can create a custom handler by
subclassing <a href="qxmldefaulthandler.html">QXmlDefaultHandler</a>, and use this to
handle both error and content events:</p>
<pre class="cpp">
     Handler <span class="operator">*</span>handler <span class="operator">=</span> <span class="keyword">new</span> Handler;
     xmlReader<span class="operator">.</span>setContentHandler(handler);
     xmlReader<span class="operator">.</span>setErrorHandler(handler);
</pre>
<p>If you don't set at least the content and error handlers, the
parser will fall back on its default behavior---and will do
nothing.</p>
<p>The most convenient way to handle the input is to read it in a
single pass using the <a href="qxmlsimplereader.html#parse">parse</a>() function with an argument
that specifies the input source:</p>
<pre class="cpp">
     <span class="type">bool</span> ok <span class="operator">=</span> xmlReader<span class="operator">.</span>parse(source);

     <span class="keyword">if</span> (<span class="operator">!</span>ok)
         std<span class="operator">.</span>cout <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">"Parsing failed."</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> std<span class="operator">.</span>endl;
</pre>
<p>If you can't parse the entire input in one go (for example, it
is huge, or is being delivered over a network connection), data can
be fed to the parser in pieces. This is achieved by telling
<a href="qxmlsimplereader.html#parse">parse</a>() to work
incrementally, and making subsequent calls to the <a href="qxmlsimplereader.html#parseContinue">parseContinue</a>() function,
until all the data has been processed.</p>
<p>A common way to perform incremental parsing is to connect the
<tt>readyRead()</tt> signal of a <a href="qnetworkreply.html">network reply</a> a slot, and handle the
incoming data there. See <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a>.</p>
<p>Aspects of the parsing behavior can be adapted using <a href="qxmlsimplereader.html#setFeature">setFeature</a>() and <a href="qxmlsimplereader.html#setProperty">setProperty</a>().</p>
<pre class="cpp">
 xmlReader<span class="operator">.</span><a href="qxmlsimplereader.html#setFeature">setFeature</a>(<span class="string">"http://xml.org/sax/features/namespace-prefixes"</span><span class="operator">,</span> <span class="keyword">true</span>);
</pre>
<p>QXmlSimpleReader is not reentrant. If you want to use the class
in threaded code, lock the code using QXmlSimpleReader with a
locking mechanism, such as a <a href="qmutex.html">QMutex</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlSimpleReader" />QXmlSimpleReader.__init__ (<i>self</i>)</h3><p>Constructs a simple XML reader.</p>


<h3 class="fn"><a name="contentHandler" /><a href="qxmlcontenthandler.html">QXmlContentHandler</a> QXmlSimpleReader.contentHandler (<i>self</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#contentHandler">QXmlReader.contentHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setContentHandler">setContentHandler</a>().</p>


<h3 class="fn"><a name="declHandler" /><a href="qxmldeclhandler.html">QXmlDeclHandler</a> QXmlSimpleReader.declHandler (<i>self</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#declHandler">QXmlReader.declHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setDeclHandler">setDeclHandler</a>().</p>


<h3 class="fn"><a name="DTDHandler" /><a href="qxmldtdhandler.html">QXmlDTDHandler</a> QXmlSimpleReader.DTDHandler (<i>self</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#DTDHandler">QXmlReader.DTDHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setDTDHandler">setDTDHandler</a>().</p>


<h3 class="fn"><a name="entityResolver" /><a href="qxmlentityresolver.html">QXmlEntityResolver</a> QXmlSimpleReader.entityResolver (<i>self</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#entityResolver">QXmlReader.entityResolver</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setEntityResolver">setEntityResolver</a>().</p>


<h3 class="fn"><a name="errorHandler" /><a href="qxmlerrorhandler.html">QXmlErrorHandler</a> QXmlSimpleReader.errorHandler (<i>self</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#errorHandler">QXmlReader.errorHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setErrorHandler">setErrorHandler</a>().</p>


<h3 class="fn"><a name="feature" />(bool, bool&#160;<i>ok</i>) QXmlSimpleReader.feature (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#feature">QXmlReader.feature</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setFeature">setFeature</a>().</p>


<h3 class="fn"><a name="hasFeature" />bool QXmlSimpleReader.hasFeature (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#hasFeature">QXmlReader.hasFeature</a>().</p>


<h3 class="fn"><a name="hasProperty" />bool QXmlSimpleReader.hasProperty (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#hasProperty">QXmlReader.hasProperty</a>().</p>


<h3 class="fn"><a name="lexicalHandler" /><a href="qxmllexicalhandler.html">QXmlLexicalHandler</a> QXmlSimpleReader.lexicalHandler (<i>self</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#lexicalHandler">QXmlReader.lexicalHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setLexicalHandler">setLexicalHandler</a>().</p>


<h3 class="fn"><a name="parse" />bool QXmlSimpleReader.parse (<i>self</i>, <a href="qxmlinputsource.html">QXmlInputSource</a>&#160;<i>input</i>)</h3><p>Reimplemented from <a class="obsolete" href="qxmlreader-obsolete.html#parse-2">QXmlReader.parse</a>().</p>


<h3 class="fn"><a name="parse-2" />bool QXmlSimpleReader.parse (<i>self</i>, <a href="qxmlinputsource.html">QXmlInputSource</a>&#160;<i>input</i>, bool&#160;<i>incremental</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#parse">QXmlReader.parse</a>().</p>
<p>Reads an XML document from <i>input</i> and parses it in one
pass (non-incrementally). Returns true if the parsing was
successful; otherwise returns false.</p>


<h3 class="fn"><a name="parseContinue" />bool QXmlSimpleReader.parseContinue (<i>self</i>)</h3><p>Continues incremental parsing, taking input from the <a href="qxmlinputsource.html">QXmlInputSource</a> that was specified with
the most recent call to <a href="qxmlsimplereader.html#parse">parse</a>(). To use this function,
you <i>must</i> have called <a href="qxmlsimplereader.html#parse">parse</a>() with the incremental
argument set to true.</p>
<p>Returns false if a parsing error occurs; otherwise returns true,
even if the end of the XML file has not been reached. You can
continue parsing at a later stage by calling this function again
when there is more data available to parse.</p>
<p>Calling this function when there is no data available in the
input source indicates to the reader that the end of the XML file
has been reached. If the input supplied up to this point was not
well-formed then a parsing error occurs, and false is returned. If
the input supplied was well-formed, true is returned. It is
important to end the input in this way because it allows you to
reuse the reader to parse other XML files.</p>
<p>Calling this function after the end of file has been reached,
but without available data will cause false to be returned whether
the previous input was well-formed or not.</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#parse">parse</a>(), <a href="qxmlinputsource.html#data">QXmlInputSource.data</a>(), and
<a href="qxmlinputsource.html#next">QXmlInputSource.next</a>().</p>


<h3 class="fn"><a name="property" />(sip.voidptr, bool&#160;<i>ok</i>) QXmlSimpleReader.property (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#property">QXmlReader.property</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#setProperty">setProperty</a>().</p>


<h3 class="fn"><a name="setContentHandler" />QXmlSimpleReader.setContentHandler (<i>self</i>, <a href="qxmlcontenthandler.html">QXmlContentHandler</a>&#160;<i>handler</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setContentHandler">QXmlReader.setContentHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#contentHandler">contentHandler</a>().</p>


<h3 class="fn"><a name="setDeclHandler" />QXmlSimpleReader.setDeclHandler (<i>self</i>, <a href="qxmldeclhandler.html">QXmlDeclHandler</a>&#160;<i>handler</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setDeclHandler">QXmlReader.setDeclHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#declHandler">declHandler</a>().</p>


<h3 class="fn"><a name="setDTDHandler" />QXmlSimpleReader.setDTDHandler (<i>self</i>, <a href="qxmldtdhandler.html">QXmlDTDHandler</a>&#160;<i>handler</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setDTDHandler">QXmlReader.setDTDHandler</a>().</p>


<h3 class="fn"><a name="setEntityResolver" />QXmlSimpleReader.setEntityResolver (<i>self</i>, <a href="qxmlentityresolver.html">QXmlEntityResolver</a>&#160;<i>handler</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setEntityResolver">QXmlReader.setEntityResolver</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#entityResolver">entityResolver</a>().</p>


<h3 class="fn"><a name="setErrorHandler" />QXmlSimpleReader.setErrorHandler (<i>self</i>, <a href="qxmlerrorhandler.html">QXmlErrorHandler</a>&#160;<i>handler</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setErrorHandler">QXmlReader.setErrorHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#errorHandler">errorHandler</a>().</p>


<h3 class="fn"><a name="setFeature" />QXmlSimpleReader.setFeature (<i>self</i>, QString&#160;<i>name</i>, bool&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setFeature">QXmlReader.setFeature</a>().</p>
<p>Turns on the feature <i>name</i> if <i>enable</i> is true;
otherwise turns it off.</p>
<p>The <i>name</i> parameter must be one of the following
strings:</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Feature</th>
<th>Default</th>
<th>Notes</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td><i>http://xml.org/sax/features/namespaces</i></td>
<td>true</td>
<td>If enabled, namespaces are reported to the content
handler.</td>
</tr>
<tr class="even" valign="top">
<td><i>http://xml.org/sax/features/namespace-prefixes</i></td>
<td>false</td>
<td>If enabled, the original prefixed names and attributes used for
namespace declarations are reported.</td>
</tr>
<tr class="odd" valign="top">
<td>
<i>http://trolltech.com/xml/features/report-whitespace-only-CharData</i></td>
<td>true</td>
<td>If enabled, CharData that consist of only whitespace characters
are reported using <a href="qxmlcontenthandler.html#characters">QXmlContentHandler.characters</a>().
If disabled, whitespace is silently discarded.</td>
</tr>
<tr class="even" valign="top">
<td>
<i>http://trolltech.com/xml/features/report-start-end-entity</i></td>
<td>false</td>
<td>If enabled, the parser reports
QXmlContentHandler.startEntity() and
QXmlContentHandler.endEntity() events, so character data might be
reported in chunks. If disabled, the parser does not report these
events, but silently substitutes the entities, and reports the
character data in one chunk.</td>
</tr>
</table>
<p><b>See also</b> <a href="qxmlsimplereader.html#feature">feature</a>(), <a href="qxmlsimplereader.html#hasFeature">hasFeature</a>(), and <a href="xml-sax.html#sax2-features">SAX2 Features</a>.</p>


<h3 class="fn"><a name="setLexicalHandler" />QXmlSimpleReader.setLexicalHandler (<i>self</i>, <a href="qxmllexicalhandler.html">QXmlLexicalHandler</a>&#160;<i>handler</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setLexicalHandler">QXmlReader.setLexicalHandler</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#lexicalHandler">lexicalHandler</a>().</p>


<h3 class="fn"><a name="setProperty" />QXmlSimpleReader.setProperty (<i>self</i>, QString&#160;<i>name</i>, sip.voidptr&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qxmlreader.html#setProperty">QXmlReader.setProperty</a>().</p>
<p><b>See also</b> <a href="qxmlsimplereader.html#property">property</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>